/*
 * This file is part of the Sx Framework Library.
 * 
 * Copyright (C) 2013 University of Colorado Denver
 * <min.choi@ucdenver.edu> <shane.transue@ucdenver.edu>
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy 
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
 * copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in 
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 */
#include <sxLong.h>
#include <limits>

Sx::Long::Long() {
	this->value = 0;
}

Sx::Long::Long(const Long& l) {
	this->value = l.value;
}

Sx::Long::Long(long value) {
	this->value = value;
}

Sx::Long::Long(float value) {
	this->value = static_cast<long>(value);
}

Sx::Long::Long(double value) {
	this->value = static_cast<long>(value);
}

Sx::Long::Long(short value) {
	this->value = static_cast<long>(value);
}

Sx::Long::Long(int value) {
	this->value = static_cast<long>(value);
}

Sx::Long::~Long() {}

void Sx::Long::set(long value) {
	this->value = value;
}

long Sx::Long::data() const {
	return this->value;
}

Sx::Long::operator long () const {
	return this->value;
}

Sx::Long Sx::Long::Max() {
	return std::numeric_limits<long>::max();
}

Sx::Long Sx::Long::Min() {
	return std::numeric_limits<long>::min();
}

Sx::Long Sx::Long::Infinity() {
	return std::numeric_limits<long>::infinity();
}

unsigned long Sx::Long::ToUnsignedLong(const Long& l) {
	return static_cast<unsigned long>(l.value);
}

Sx::Long Sx::Long::operator + (const Long& l) {
	return Long(this->value + l.value);
}

Sx::Long Sx::Long::operator + (long l) {
	return Long(this->value + l);
}

Sx::Long Sx::Long::operator - (const Long& l) {
	return Long(this->value - l.value);
}

Sx::Long Sx::Long::operator - (long l) {
	return Long(this->value - l);
}

Sx::Long Sx::Long::operator * (const Long& l) {
	return Long(this->value * l.value);
}

Sx::Long Sx::Long::operator * (long l) {
	return Long(this->value * l);
}

Sx::Long Sx::Long::operator / (const Long& l) {
	return Long(this->value / l.value);
}

Sx::Long Sx::Long::operator / (long l) {
	return Long(this->value / l);
}

void Sx::Long::operator += (const Long& l) {
	this->value += l.value;
}

void Sx::Long::operator += (long l) {
	this->value += l;
}

void Sx::Long::operator -= (const Long& l) {
	this->value -= l.value;
}

void Sx::Long::operator -= (long l) {
	this->value -= l;
}

void Sx::Long::operator *= (const Long& l) {
	this->value *= l.value;
}

void Sx::Long::operator *= (long l) {
	this->value *= l;
}

void Sx::Long::operator /= (const Long& l) {
	this->value /= l.value;
}

void Sx::Long::operator /= (long l) {
	this->value /= l;
}

void Sx::Long::operator = (const Long& l) {
	this->value = l.value;
}

void Sx::Long::operator = (long l) {
	this->value = l;
}

bool Sx::Long::operator == (const Long& l) {
	if ( this->value == l.value ) return true;
	else return false;
}

bool Sx::Long::operator != (const Long& l) {
	if ( this->value == l.value ) return false;
	else return true;
}

bool Sx::Long::operator == (long l) {
	if ( this->value == l ) return true;
	else return false;
}

bool Sx::Long::operator != (long l) {
	if ( this->value == l ) return false;
	else return true;
}

bool Sx::Long::operator <= (const Long& l) {
	if ( this->value <= l.value ) return true;
	else return false;
}

bool Sx::Long::operator <= (long l) {
	if ( this->value <= l ) return true;
	else return false;
}

bool Sx::Long::operator >= (const Long& l) {
	if ( this->value >= l.value ) return true;
	else return false;
}

bool Sx::Long::operator >= (long l) {
	if ( this->value >= l ) return true;
	else return false;
}

bool Sx::Long::operator < (const Long &l) {
	if ( this->value < l.value ) return true;
	else return false;
}

bool Sx::Long::operator < (long l) {
	if ( this->value < l ) return true;
	else return false;
}

bool Sx::Long::operator > (const Long &l) {
	if ( this->value > l.value ) return true;
	else return false;
}

bool Sx::Long::operator > (long l) {
	if ( this->value > l ) return true;
	else return false;
}

Sx::Long operator + (long v, const Sx::Long& l) {
	Sx::Long r(v);
	r += l;
	return r;
}

Sx::Long operator - (long v, const Sx::Long& l) {
	Sx::Long r(v);
	r -= l;
	return r;
}

Sx::Long operator * (long v, const Sx::Long& l) {
	Sx::Long r(v);
	r *= l;
	return r;
}

Sx::Long operator / (long v, const Sx::Long& l) {
	Sx::Long r(v);
	r /= l;
	return r;
}

std::ostream& operator << (std::ostream &out, const Sx::Long& l) {
	out << static_cast<long>(l);
	return out;
}
